import 'package:animal/model/id_name_model.dart';
import 'package:animal/ui/friend/model/friend_addply_num_model.dart';
import 'package:animal/ui/friend/model/friend_model.dart';
import 'package:animal/ui/friend/model/new_friend_model.dart';
import 'package:animal/ui/friend/model/search_user_model.dart';
import 'package:animal/ui/login/model/short_login_model.dart';

class EntityFactory {
  static generateOBJ<T>(json) {
    ///model的判断
    if (T.toString() == "IdNameModel") {
      return IdNameModel.fromJson(json);
    }else if (T.toString() == "ShortLoginModel") {
      return ShortLoginModel.fromJson(json);
    }else if (T.toString() == "SearchUserModel") {
      return SearchUserModel.fromJson(json);
    }else if (T.toString() == "NewFriendModel") {
      return NewFriendModel.fromJson(json);
    }else if (T.toString() == "FriendAddplyNumModel") {
      return FriendAddplyNumModel.fromJson(json);
    }else if (T.toString() == "List<FriendModel>") {
      return (json as List).map((v) => FriendModel.fromJson(v)).toList();
    }

    ///listModel的判断
    // else if (T.toString() == "List<IdNameModel>") {
    //   return (json as List).map((v) => IdNameModel.fromJson(v)).toList();
    // }
  }
}
